package com.o2o.service.impl;

import com.o2o.cache.JedisUtil;
import com.o2o.service.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * package_name:com.o2o.service.impl
 * Author:徐亚远
 * Date:2019/12/25 18:42
 * 项目名:o2o
 * Desription:
 **/
@Service
public class CacheServiceImpl implements CacheService {
    @Autowired
    private JedisUtil.Keys jedisKeys;


    /*
    * 删除redis中的键
    * @param keyPreFix
    *
    * */
    @Override
    public void removeFromCache(String keyPrefix) {
        Set<String> keySet = jedisKeys.keys(keyPrefix + "*");
        for (String key : keySet){
            jedisKeys.del(key);
        }
    }
}
